package SSCLIB.SST2.PWD;

import SSCLIB.*;

//	using System;
//	using System.IO;
//	using System.Security.Cryptography;
//	using System.Text;



//shenfarzhar
public class SidEncrypt
{
	private String sKey = "cm818com";

	public final String Decrypt(String pToDecrypt)
	{
		try
		{
			DESCryptoServiceProvider provider = new DESCryptoServiceProvider();
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: byte[] buffer = new byte[pToDecrypt.Length / 2];
			byte[] buffer = new byte[pToDecrypt.length() / 2];
			for (int i = 0; i < (pToDecrypt.length() / 2); i++)
			{
				int num2 = (int)(pToDecrypt.substring(i * 2, i * 2 + 2), 0x10);
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: buffer[i] = (byte)num2;
				buffer[i] = (byte)num2;
			}
			provider.Key = Encoding.ASCII.GetBytes(this.sKey);
			provider.IV = Encoding.ASCII.GetBytes(this.sKey);
			MemoryStream stream = new MemoryStream();
			try //t545
			{
				CryptoStream stream2 = new CryptoStream(stream, provider.CreateDecryptor(), CryptoStreamMode.Write);
				stream2.Write(buffer, 0, buffer.length);
				stream2.FlushFinalBlock();
			}
			catch (java.lang.Exception e)
			{
				;
			}
			StringBuilder builder = new StringBuilder();
			return Encoding.Default.GetString(stream.ToArray());
		}
		catch (java.lang.Exception e2)
		{
			return pToDecrypt;
		}
	}

	public final String Encrypt(String pToEncrypt)
	{
		try
		{
		DESCryptoServiceProvider provider = new DESCryptoServiceProvider();
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: byte[] bytes = Encoding.Default.GetBytes(pToEncrypt);
		byte[] bytes = Encoding.Default.GetBytes(pToEncrypt);
		provider.Key = Encoding.ASCII.GetBytes(this.sKey);
		provider.IV = Encoding.ASCII.GetBytes(this.sKey);
		MemoryStream stream = new MemoryStream();
		CryptoStream stream2 = new CryptoStream(stream, provider.CreateEncryptor(), CryptoStreamMode.Write);
		stream2.Write(bytes, 0, bytes.length);
		stream2.FlushFinalBlock();
		StringBuilder builder = new StringBuilder();
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: foreach (byte num in stream.ToArray())
		for (byte num : stream.ToArray())
		{
			builder.append(String.format("%02X", num));
		}
		builder.toString();
		return builder.toString();
		}
	catch (java.lang.Exception e)
	{
		return pToEncrypt;
	}
	}

	public final String getSecurityKey()
	{
		return this.sKey;
	}
	public final void setSecurityKey(String value)
	{
		this.sKey = value;
	}
}